import Page
from Page import Personal
from Base.Base import Base
from selenium.webdriver.common.by import By


class PersonalAvatarPage(Base):
    """
    个人中心头像弹窗
    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的home键
        self.avatar_home_btn = (By.XPATH, Personal.RESOURCE_ID.format("ivHome"))

        # 左侧的返回键
        self.avatar_back_btn = (By.XPATH, Personal.RESOURCE_ID.format('ivBack'))

        # 头像标题
        self.avatar_title_text = (By.XPATH, Personal.RESOURCE_ID.format("change_tips"))

        # 二维码
        self.avatar_qr_code_icon = (By.XPATH, Personal.RESOURCE_ID.format("change_qr"))

        # 提示
        self.avatar_tip_text = (By.XPATH, Personal.RESOURCE_ID.format("change_sub_tips"))

        # 确认按钮
        self.avatar_sure_btn = (By.XPATH, Personal.RESOURCE_ID.format("change_complete_tv"))

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.avatar_home_btn)

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.avatar_home_btn)

    def get_title(self):
        """
        获取头像标题

        :return:
        """
        return self.find_element_o(self.avatar_title_text)

    def get_qr_code(self):
        """
        获取头像二维码

        :return:
        """
        return self.find_element_o(self.avatar_qr_code_icon)

    def get_tip(self):
        """
        获取头像提示

        :return:
        """
        return self.find_element_o(self.avatar_tip_text)

    def click_sure(self):
        """
        点击确认按钮

        :return:
        """
        self.click_element(self.avatar_sure_btn)

    def is_display_personal_avatar(self):
        """
        是否存在头像页

        :return: bool
        """
        return self.is_display(self.avatar_title_text)
